from concurrent.futures import ThreadPoolExecutor


class CheckerBase:
    def __init__(self, ssh_client):
        self.ssh = ssh_client

    def run_command(self, cmd):
        stdin, stdout, stderr = self.ssh.exec_command(cmd)
        result = stdout.read().decode().strip()
        result_err = stderr.read().decode().strip()
        return result, result_err

    @staticmethod
    def run_checks(check_functions, num_threads=4):
        with ThreadPoolExecutor(max_workers=num_threads) as executor:
            results = list(executor.map(lambda f: f(), check_functions))
        return results
